﻿<template>
    <div>
        <h1>登录页面</h1>
        <label for="user">账户：<input type="text" v-model="userObj.user" id="user" name="user"></label>
        <br>
        <label for="pwd">密码：<input type="text" v-model="userObj.pwd" id="pwd" name="pwd"></label>
        <br>
        <button @click="loginUser">登录</button>
    </div>
</template>

<script>
    import utils from "../utils/utils";

    export default {
        name: "login",
        data(){
          return{
              userObj:{
                  user:'',
                  pwd:''
              }
          }
        },
        methods:{
            loginUser(){
                let {user,pwd}=this.userObj
                utils.setStorage('user',this.userObj)
                if (this.userObj.user!=''&&this.userObj.pwd!=''){
                    this.$router.push('/home/student')
                }else {
                    alert('请输入账号密码')
                    this.$router.push('/login')
                }

            }
        }
    }
</script>

<style scoped>

</style>